﻿using JwtDemo.Consts;
using JwtDemo.Interface;
using JwtDemo.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;

namespace JwtDemo.Controllers
{
    [Authorize(AppConst.User)]
   // [Authorize(Roles = AppConst.User)]
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;
        private readonly IUserContext _user;

        public HomeController(ILogger<HomeController> logger, IUserContext user)
        {
            _logger = logger;
            _user = user;
        }

        public IActionResult Index()
        {
            var name = _user.Username;
            return View();
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
